<?php
/**
 * 模块启动文件
 */
namespace addons\links;
use addons\links\controller\Index;
use system\Addon;
use system\MyError;

class Links extends Addon {
    public function getName()
    {
        return 'links';
    }

    public function getVersion()
    {
        return '1.0.0';
    }

    public function getAuthor()
    {
        return 'major';
    }

    public function getDesc()
    {
        return '友情链接';
    }

    public function install()
    {
    	$sql['1.0.0'] = "CREATE TABLE IF NOT EXISTS `@links`(
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `linktype` tinyint(1) DEFAULT NULL COMMENT '0:文字,1:logo',
  `url` varchar(200) DEFAULT NULL COMMENT '链接地址',
  `name` varchar(20) DEFAULT NULL COMMENT '链接名称',
  `image` varchar(200) DEFAULT NULL COMMENT '链接图片',
  `description` varchar(255) DEFAULT NULL COMMENT '描述',
  `sort` int(5) DEFAULT '0' COMMENT '排序',
  `create_time` int(10) DEFAULT NULL COMMENT '添加时间',
  `update_time` int(10) DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`)
) ENGINE=myisam DEFAULT charset=utf8 comment='友情链接';";
		return $sql;
    }

    public function uninstall() {
		$sql['1.0.0'] = "DROP TABLE `@links`;";
		return $sql;
	}

	public function onInitMenu(&$data = []){
		return [
			[
				'name'  => 'links',
				'title' => '友情链接',
				'icon'  => 'layui-icon-user',
				'list'  => [
					['name' => 'links', 'title' => '友情链接', 'auth_name' => Index::class, 'action' => 'index' , 'jump' => '---links/index'],
				]
			],
		];
	}
}